<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%><jsp:include page="../admin.jsp"></jsp:include>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>${param.pageTitle }--${site.name }</title>
<meta name="description" content="${site.description }" />
<meta name="keywords" content="${site.keywords}" />
<jsp:include page="../../../inc/js.jsp"></jsp:include>
<jsp:include page="../../../inc/css.jsp"></jsp:include>
<script type="text/javascript">
function movePage(pageNo) {
	window.location = '?pageNo=' + pageNo + param()
			+ '&pageTitle=${param.pageTitle }';
}
function param() {
	var param = "";
	if ($("#classCode").val() != "")
		param += '&classCode=' + $("#classCode").val();
	if ($("#title").val() != "")
		param += '&title=' + $("#title").val();
	if ($("#description").val() != "")
		param += '&description=' + $("#description").val();
	return param;
}
$(document).ready(
		function() {
			$.get("getSelect.do", {
				type : 'ms',
				index : '${param.classCode}',
				code : null
			}, function(data) {
				$("select#classCode").append(data);
			});
			$("#search").button().click(function() {
				movePage(1);
			});
			$.get("topMsgList.do?top=10&type=fix&short&" + Math.random(),
					function(data) {
						$("#topMFix").append(data);
					});
			$.get("topMsgList.do?top=10&type=view&short&" + Math.random(),
					function(data) {
						$("#topMView").append(data);
					});
		});
function fix(id, fix) {
	if (confirm('确定推荐/取消？'))
		$.ajax( {
					type : "post",
					url : "fixMsg.do?fix=" + fix + "&id=" + id,
					dataType : 'json',
					error : function() {
						alert("加载错误");
					},
					success : function(data) {
						if (data.success) {
							alert('操作成功！');
							location = '?classCode=${param.classCode}&&pageTitle=${param.pageTitle}';
						} else
							alert("操作失败！" + data.err);
					}
				});
}
function del(id) {
	if (confirm('确认删除？')) {
		$
				.ajax( {
					type : "get",
					url : "deleteMsg.do",
					data : {
						id : id
					},
					dataType : 'json',
					error : function() {
						alert("加载错误");
					},
					success : function(data) {
						if (data.success) {
							alert('操作成功！');
							location = '?classCode=${param.classCode}&&pageTitle=${param.pageTitle}';
						} else
							alert('操作失败！\r\n' + data.err);
					}
				});
	}
}
</script>
</head>
<body>
<jsp:include page="functionPath.jsp">
	<jsp:param value="${url}" name="url"/>
</jsp:include>
<table cellpadding="0" cellspacing="1" class="list">
	<thead>
		<tr>
			<td class="search"><select id="classCode">
				<option value="">请选择类别</option>
			</select> <label> 标题： </label> <input type="text" name="title" id="title"
				value="${param.title }" /> <label> 内容： </label> <input type="text"
				name="description" id="description" value="${param.description }" />
			<button id="search">查询</button>
			</td>
		</tr>
	</thead>
	<tbody>
		<c:forEach var="e" items="${o.dataList}" varStatus="s">
			<tr>
				<td><a
					href="?pageTitle=${param.pageTitle }&classCode=${e.classCode}">
				[${e.className}] </a> <a href="showMsg.do?id=${e.id}" target="_blank">
				${e.title}</a> <c:if test="${e.fix>0}">
					<font color="red">[推荐]</font>
				</c:if> <span class="date" style="float: right; margin-right: 10px;">
				<fmt:formatDate value="${e.inputdate}" pattern="yyyy/MM/dd" />
				浏览：${e.views} <c:if test="${admin!=null}">
					<c:if test="${e.fix==0}">
						<a href="javascript:fix(${e.id},1);"> <img
							src="lib/images/up.gif" /> </a>
					</c:if>
					<c:if test="${e.fix>0}">
						<a href="javascript:fix(${e.id},0);"> <img
							src="lib/images/last.gif" /> </a>
					</c:if>
					<a href="javascript:del(${e.id});"> <img
						src="lib/images/close.gif" /> </a>
				</c:if> </span></td>
			</tr>
		</c:forEach>
	</tbody>
	<tfoot>
		<tr>
			<td>${o.pageNav }</td>
		</tr>
	</tfoot>
</table>
</body>
</html>